import request from '@/utils/request'
import type { 
  ApiResponse, 
  Category, 
  CategoryRequest, 
  PageResult,
  PageParams
} from '@/types'

// 分类相关API
export const categoryApi = {
  // 获取分类列表
  getCategoryList: (params: PageParams): Promise<ApiResponse<PageResult<Category>>> => {
    return request.get('/categories', { params })
  },

  // 创建分类
  createCategory: (data: CategoryRequest): Promise<ApiResponse<Category>> => {
    return request.post('/categories', data)
  },

  // 更新分类
  updateCategory: (id: number, data: Partial<CategoryRequest>): Promise<ApiResponse<Category>> => {
    return request.put(`/categories/${id}`, data)
  },

  // 删除分类
  deleteCategory: (id: number): Promise<ApiResponse<string>> => {
    return request.delete(`/categories/${id}`)
  }
}